<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <input type="text">

  <script>
    let ipt = document.querySelector('input');
    // 当文本框内容改变，失去焦点时候触发
    /* ipt.onchange = function () {
      console.log(ipt.value);
    } */

    // 失去焦点时候触发，不管值是否改变
    /* ipt.onblur = function () {
      console.log(ipt.value);
    } */

    // oninput 内容发生改变就触发
    ipt.oninput = function () {
      console.log(ipt.value);
    }
  </script>
</body>
</html>